
////// window for widget setting

var modModalWidgetSetting = new Class({
	Extends:boxWindow,
	options: $extend({
		BtnRefresh: false,
		BtnMin: false,
		BtnSettings: false,
		title: "",
		name: 'modModalWidgetSetting',
		uniqueCss: true,
		modal: true,
		BtnClose: true,
		fixed: true,
		left:0,
		top:0,
		width:600,
		isBox:false
	}),
	callerthis:null,
	settingBox:null,
	callbackfunction:null,

	///// get where to display the box
	initialize: function(callerthis,settingBox){
	  this.parent();
		this.callerthis=callerthis;
		this.settingBox=settingBox;
	}, 

	/////// load the info in the box
	onFinish: function(){
		var posx = (getWidth()/2 )-(this.options.width/2);
		var posy = (getHeight()/2)-(this.options.height/2);
		var overLay = $('modaloverlay');
		var modCss = this.options.uniqueCss ? this.options.name : '';		
		if(this.options.isBox){
			overLay.setStyle('width', this.options.width+'px'); 
			overLay.setStyle('height', this.options.height+'px'); 
			overLay.setStyle('top', posy); 
			//overLay.setStyle('left', posx); 
		} else { 
			overLay.setStyle('width', this.options.width+'px');
			overLay.setStyle('top' , 50); 
			//overLay.setStyle('left', posx); 
		}
		var item_wrap = new Element('div').injectInside(this.contentBox);
		this.settingBox.injectInside(item_wrap);
		$('overlay').setStyle("height",getScrollHeight()+"px");
		overLay.setStyle("padding",0);
		overLay.getElements('td[class^=modModalWidgetSettingwindow_caption_]').setStyle("border-bottom",0);
		this.callerthis.boxObject.fireEvent('AfterWidgetModalSettingFinish',null);		
	},
	
	dialogcancel:function(){
		var btn = this.callerthis.boxObject.getElement('.btn_settings');
		if ($chk($(btn))) {
			if (this.callerthis.options.BtnSettingsText) {
				btn.innerHTML = lang.label('widget_btn_setting');
			}
			if (this.callerthis.options.BtnSettingsClass) {
				btn.parentNode.removeClass('editing');
			}
			btn.setAttribute('title', lang.label('widget_btn_setting'));
			btn.setAttribute('editing', '');
		}
	},
	
	closeModal:function(){
		this.callerthis.boxObject.fireEvent('BeforeWidgetModalSettingClose',null);
		this.dialogcancel();
		this.callerthis=null;
		this.settingBox=null;
		this.parent();
	}
});


